﻿namespace DataTanker
{
    using System;

    using Settings;

    /// <summary>
    /// Provides methods to create storage instances.
    /// </summary>
    public interface IStorageFactory
    {
        /// <summary>
        /// Creates a new storage instance with specified types of keys and values.
        /// </summary>
        /// <typeparam name="TKey">The type of key</typeparam>
        /// <typeparam name="TValue">The type of value</typeparam>
        /// <param name="keySerializer">Object implementing ISerializer interface for key serialization</param>
        /// <param name="valueSerializer">Object implementing ISerializer interface for value serialization</param>
        /// <param name="settings">Setiings of creating storage</param>
        /// <returns>New storage instance</returns>
        IKeyValueStorage<KeyOf<TKey>, ValueOf<TValue>> CreateStorage<TKey, TValue>(ISerializer<TKey> keySerializer, ISerializer<TValue> valueSerializer, StorageSettings settings)
            where TKey : IComparable;


        /// <summary>
        /// Creates a new storage instance with specified types of keys and values.
        /// </summary>
        /// <typeparam name="TKey">The type of key</typeparam>
        /// <typeparam name="TValue">The type of value</typeparam>
        /// <param name="serializeKey">Key serialization method</param>
        /// <param name="deserializeKey">Key deserialization method</param>
        /// <param name="serializeValue">Value serialization method</param>
        /// <param name="deserializeValue">Value deserialization method</param>
        /// <param name="settings">Setiings of creating storage</param>
        /// <returns>New storage instance</returns>
        IKeyValueStorage<KeyOf<TKey>, ValueOf<TValue>> CreateStorage<TKey, TValue>(
            Func<TKey, byte[]> serializeKey,
            Func<byte[], TKey> deserializeKey,
            Func<TValue, byte[]> serializeValue,
            Func<byte[], TValue> deserializeValue,
            StorageSettings settings)

            where TKey : IComparable;

        /// <summary>
        /// Creates a new bytearray storage instance with specified type of keys.
        /// </summary>
        /// <typeparam name="TKey">The type of key</typeparam>
        /// <param name="serializeKey">Key serialization method</param>
        /// <param name="deserializeKey">Key deserialization method</param>
        /// <param name="settings">Setiings of creating storage</param>
        /// <returns>New storage instance</returns>
        IKeyValueStorage<KeyOf<TKey>, ValueOf<byte[]>> CreateByteArrayStorage<TKey>(
            Func<TKey, byte[]> serializeKey,
            Func<byte[], TKey> deserializeKey,
            StorageSettings settings) 
            
            where TKey : IComparable;
    }
}